package com.wuba.rxjavademo.lyz.day0602;

import com.wuba.rxjavademo.lyz.BaseDemo;

import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Action1;
import rx.functions.Func1;

/**
 * Created by liyaxing on 2016/6/13.
 */
public class Demo06 extends BaseDemo {

    public static void main(String[] ss){

        Observable observable = Observable.create(new Observable.OnSubscribe<Integer>() {
            @Override
            public void call(Subscriber<? super Integer> subscriber) {
                    throw new NullPointerException("xxxx") ;
            }
        }) ;

        observable.onErrorResumeNext(new Func1<Throwable, Observable>() {
            @Override
            public Observable call(Throwable throwable) {
                print("---onErrorResumeNext---");
                return Observable.just(1);
            }
        }).doOnError(new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                print("---doOnError---");
            }
        }).doOnTerminate(new Action0() {
            @Override
            public void call() {
                print("---doOnTerminate---");
            }
        }).subscribe() ;


    }



}
